// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-12-6

#ifndef __UI_ATTRIBITEM_H_COMMON_SVR_BASE__
#define __UI_ATTRIBITEM_H_COMMON_SVR_BASE__

#pragma once

#include "ui_attribview.h"
#include "net_monitor.h"

#pragma comment(lib, "psapi.lib")

namespace JoyServerAttrib
{

class Attrib_UserCount : public CJoyAttribViewItem
{
public:
    Attrib_UserCount();
    virtual void UpdateAttrib(CJoyServer* pServer);
};

class Attrib_ClientVer : public CJoyAttribViewItem
{
public:
    Attrib_ClientVer();
    virtual void UpdateAttrib(CJoyServer* pServer);
};

class Attrib_ServerName : public CJoyAttribViewItem
{
protected:
    SYSTEMTIME m_startTime;
    virtual void OnStart(CJoyServer* pServer);
public:
    Attrib_ServerName();
    virtual void UpdateAttrib(CJoyServer* pServer);
};

class Attrib_ServerAddr : public CJoyAttribViewItem
{
protected:
    virtual void OnStart(CJoyServer* pServer);
public:
    Attrib_ServerAddr();
};

class Attrib_AppAttrib : public CJoyAttribViewItem
{
protected:
    virtual void OnStop();
public:
    Attrib_AppAttrib();
};

class Attrib_ServerTime : public CJoyAttribViewItem
{
public:
    SYSTEMTIME m_startTime;

    virtual void OnStart(CJoyServer* pServer);
public:
    Attrib_ServerTime();

    virtual void UpdateAttrib(CJoyServer* pServer);
};

class Attrib_CpuTime : public CJoyAttribViewItem
{
public:
    UINT64  m_startTime;
    UINT64  m_updateTime;

    UINT64  m_startKernelTime;
    UINT64  m_updateKernelTime;

    UINT64  m_startUserTime;
    UINT64  m_updateUserTime;

    virtual void OnStart(CJoyServer* pServer);
    virtual void OnStop()
    {
    }
public:
    Attrib_CpuTime();
    virtual void UpdateAttrib();
};

class Attrib_ResourceUse : public CJoyAttribViewItem
{
public:
    int m_processorCount;

    virtual void OnStop()
    {
    }
public:
    Attrib_ResourceUse();
    virtual void UpdateAttrib();
};

class Attrib_NetworkUse : public CJoyAttribViewItem
{
public:
    class CNetData
    {
    public:
        float   m_transfer; // KB
        UINT    m_operation;
        CNetData()
        {
            m_transfer  = 0;
            m_operation = 0;
        }
    };
    class CNetProto
    {
    public:
        CNetData    m_send;
        CNetData    m_recv;
    };

    CNetProto   m_tcp;
    CNetProto   m_udp;
    DWORD       m_tick;

    virtual void OnStop()
    {
    }
    virtual void OnStart(CJoyServer* pServer);
    static void GetNetData(CNetData& nd, CJoyNetMonitor::CMonitorData& md);
    static void GetNetProto(CNetProto& np, CJoyNetMonitor::CProtoData& pd);
public:
    Attrib_NetworkUse();
    virtual void UpdateAttrib();
};

class Attrib_IOUse : public CJoyAttribViewItem
{
public:
    virtual void OnStop()
    {
    }
public:
    Attrib_IOUse();
    virtual void UpdateAttrib();
};

class Attrib_LogLevel : public CJoyAttribViewItem
{
protected:
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
public:
    virtual void OnStart(CJoyServer* pServer);
public:
    Attrib_LogLevel();
    virtual void UpdateAttrib();
    void UpdateAttrib(int logLevel);
};

} // namespace JoyServerAttrib

#endif  // __UI_ATTRIBITEM_H_COMMON_SVR_BASE__